package com.booking.action;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.lang.reflect.ParameterizedType;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.booking.bean.FileImage;
import com.booking.bean.Food;
import com.booking.bean.Foodorder;
import com.booking.bean.PageBean;
import com.booking.bean.Seller;
import com.booking.service.FileUpload;
import com.booking.service.FoodQueryService;
import com.booking.service.OrderService;
import com.booking.service.SellerQueryService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

@Controller
public class OrderMrgAction extends ActionSupport  implements ModelDriven<Foodorder>{
	
	//模型驱动使用的对象
	private Foodorder foodorder = new Foodorder();
	@Override
	public Foodorder getModel() {
		return foodorder;
	}
	@Autowired
	private OrderService service;
	private String ids;
	public String getIds() {
		return ids;
	}
	public void setIds(String ids) {
		this.ids = ids;
	}
	
	public String queryNoneOrder() throws IOException {
		List<Foodorder> noneOrder = service.queryNoneOrder(0,foodorder.getSellerid());
		
		  JSONArray object = JSONArray.fromObject(noneOrder);
          HttpServletResponse response = ServletActionContext.getResponse();
          response.setContentType("html/text;charset=UTF-8");
          response.getWriter().write(object.toString());  
        
          return null;  
	}
	public String queryDoneOrder() throws IOException {
		List<Foodorder> noneOrder = service.queryNoneOrder(1,foodorder.getSellerid());
		
		JSONArray object = JSONArray.fromObject(noneOrder);
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setContentType("html/text;charset=UTF-8");
		response.getWriter().write(object.toString());  
		
		return null;  
	}
	
	public void doneByIds() {
		service.doneByIds(ids);
	}

}
